let xingming1
let dianhua1
let xiangqing1
Page({
  data: {
   
  },
  // 姓名
  xingming(e) {
    console.log('姓名:', e.detail.value)
    xingming1 = e.detail.value
  },
  //电话
  dianhua(e) {
    console.log('电话', e.detail.value)
    dianhua1 = e.detail.value
  },
  //问题
  xiangqing(e) {
    console.log('详情', e.detail.value)
    xiangqing1 = e.detail.value
  },
  //提交触发函数
  publish(e) {
    console.log('提交的数据', e.detail.value)
    if (!xingming1) {
      wx.showToast({
        icon: 'error',
        title: '姓名为空',
      })
    } else if (!dianhua1) {
      wx.showToast({
        icon: 'error',
        title: '电话为空',
      })
    } else if (!xiangqing1) {
      wx.showToast({
        icon: 'error',
        title: '内容为空',
      })
    } else {
      wx.cloud.database().collection('suggest')
        .add({
          data: e.detail.value
        })
        .then(res => {
          console.log('提交成功', res)
        })
        .catch(err => {
          console.log('提交失败')
        })
    }
  }
})
